﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Web;

namespace Net.DataAccess
{
	public abstract class CommentProvider : DataAccess
	{
		public CommentProvider()
		{
			
		}

		public abstract CommentDetails FindByKey();

		protected virtual CommentDetails GetFromReader(IDataReader reader)
		{
			return new CommentDetails(
				reader["TypeID"].ToString(),
				(long)reader["TID"],
				(long)reader["ID"],
				reader["Body"].ToString(),
				(DateTime)reader["AddedDate"],
				reader["AddedBy"].ToString());
		}

		protected virtual List<CommentDetails> GetListFromReader(IDataReader reader)
		{
			List<CommentDetails> items = new List<CommentDetails>();
			while (reader.Read())
				items.Add(GetFromReader(reader));
			return items;
		}
	}
}